<!DOCTYPE html>
<html lang="en">
	<?php $this->load->view('vheader');?>
	<body>
		<?php $this->load->view('vnavbar'); ?>
		<div class="main-container" id="main-container">
			<script type="text/javascript">
				try{ace.settings.check('main-container' , 'fixed')}catch(e){}
			</script>

			<div class="main-container-inner">
				<a class="menu-toggler" id="menu-toggler" href="#">
					<span class="menu-text"></span>
				</a>

				<?php $this->load->view('vsidebar'); ?>
				<div class="main-content">
					<div class="breadcrumbs" id="breadcrumbs">
						<script type="text/javascript">
							try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
						</script>

						<ul class="breadcrumb">
							<li>
								<i class="icon-home home-icon"></i>
								<a href="#">Ganti Password</a>
							</li>
							<!--
							<li class="active">Dashboard</li>
							-->
						</ul><!-- .breadcrumb -->

						<div class="nav-search" id="nav-search">

						</div><!-- #nav-search -->
					</div>

					<div class="page-content">
						
						<div class="page-header">
							<h1>
								Ganti Password
								<!--
								<small>
									<i class="icon-double-angle-right"></i>
									overview &amp; stats
								</small>
								-->
							</h1>
						</div><!-- /.page-header -->
						
						<form id="forminputdata" action="" class="form-horizontal" role="form" method="post">
						<div class="col-xs-12">
							<div id="recent-box" class="widget-box transparent">
						
								<div class="widget-body">
									<div class="widget-main padding-4">
										<div class="tab-content padding-8 overflow-visible">
											
											<div class="space-4"></div>
											<div class="form-group">
												<label class="col-sm-3 control-label no-padding-right" for="password_lama"> Username </label>
											
												<div class="col-sm-9">
													<?php if($this->session->userdata('user4passchange') != '') { ?>
														<input type="text" name="username" id="username" placeholder="Username" class="col-xs-10 col-sm-5"  disabled value="<?= $this->session->userdata('user4passchange') ?>" />
													<?php $this->session->set_userdata('user4passchange', '');}else{ ?>
														<input type="text" name="username" id="username" placeholder="Username" class="col-xs-10 col-sm-5"  disabled value="<?= $this->session->userdata('username') ?>" />
													<?php } ?>
												</div>
											</div>
											<!--
											<div class="space-4"></div>
											<div class="form-group">
												<label class="col-sm-3 control-label no-padding-right" for="password_lama"> Password Lama </label>						
												<div class="col-sm-9">
													<input type="password" name="password_lama" id="password_lama" placeholder="Password Lama" class="col-xs-10 col-sm-5" />
													
												</div>
											</div>
											-->
											<div class="space-4"></div>
											<div class="form-group">
												<label class="col-sm-3 control-label no-padding-right" for="password_baru"> Password Baru </label>
											
												<div class="col-sm-9">
													<input type="password" name="password_baru" id="password_baru" placeholder="Password Baru" class="col-xs-10 col-sm-5"  />

												</div>
											</div>
								
											<div class="space-4"></div>
											<div class="form-group">
												<label class="col-sm-3 control-label no-padding-right" for="password_baru2"> Ulangi Password </label>
											
												<div class="col-sm-9">
													<input type="password" name="password_baru2" id="password_baru2" placeholder="Ulangi Password" class="col-xs-10 col-sm-5" />
													
												</div>
											</div>
																		
										</div>
									</div><!-- /widget-main -->
								</div><!-- /widget-body -->
							</div><!-- /widget-box -->
						</div>
						<!--<form id="formsimpandata" action="<?= site_url() ?>/home/fPSaveData">-->
						<div class="col-xs-12">
							<div class="clearfix form-actions">
								<div class="col-md-offset-3 col-md-9">
									<button id="simpan" class="btn btn-info" type="button">
										<i class="icon-ok bigger-110"></i>
										Simpan
									</button>  
									<!--	
									&nbsp; &nbsp; &nbsp;
									<button class="btn" type="reset">
										<i class="icon-undo bigger-110"></i>
										Reset
									</button>
									-->
								</div>
							</div>
						</div>


					</div><!-- /.page-content -->
				</div><!-- /.main-content -->

			<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
				<i class="icon-double-angle-up icon-only bigger-110"></i>
			</a>
		</div><!-- /.main-container -->

		<!-- basic scripts -->

		<!--[if !IE]> -->

		<script type="text/javascript">
			window.jQuery || document.write("<script src='<?= base_url() ?>assets/js/jquery-2.0.3.min.js'>"+"<"+"/script>");
		</script>

		<!-- <![endif]-->

		<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='<?= base_url() ?>assets/js/jquery-1.10.2.min.js'>"+"<"+"/script>");
</script>
<![endif]-->

		<!-- inline scripts related to this page -->
		<script type="text/javascript">
      		$(document).ready(function(){
            	$("#simpan").click(function(){
            		var username = $("#username").val();
            		var password_lama = $("#password_lama").val();
            		var password = $("#password_baru").val();
            		var password2 = $("#password_baru2").val();
            		
            		var dataString = 'username='+ username +'&password='+ password +'&password_lama='+ password_lama;

            		if((password == '') || (password != password2))
            		{
            			alert("Password baru tidak sama");
            		}
            		else
            		{            		
            			$.ajax({
            				type: "POST",
            				url:siteUrl+'/user/fgantipassword/'+username,
            				data: dataString,
            				cache: false,
            				success: function(result)
            				{
            					alert("Perubahan Password Berhasil");
            				    window.location = siteUrl+"/user/index";
            				}
            			});
            		}
            		return false;
            	});
            });
        </script> 

	</body>
</html>
